<?php
switch($action){
	/************************************** settings BEGIN ************************************************/
	case "settings":
	$row=getSettings();
echo <<<EOT
	<style>
		.td_1{width:320px;}
	</style>
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div id="t1">
		<form id="settingsform" onsubmit="return false;">
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">论坛名称:<span class='required'>(*)</span></td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="30" value="{$row['bbsname']}" name="settings[bbsname]" id="bbsname" class="text_css" /></td><td class="td_2">论坛名称，将显示在导航条和标题中</td></tr>
			<tr><td class="td_0">论坛 URL:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="30" value="{$row['url']}" name="settings[url]" id="url" class="text_css" /></td><td class="td_2">网站 URL，将作为链接显示在页面底部</td></tr>
			<tr><td class="td_0">网站备案信息代码:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="30" value="{$row['icp']}" name="settings[icp]" id="icp" class="text_css" /></td><td class="td_2">页面底部可以显示 ICP 备案信息，如果网站已备案，在此输入您的授权码，它将显示在页面底部，如果没有请留空</td></tr>
			<tr><td class="td_0">论坛关闭:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="radio" value="1" name="settings[isoff]" class="radio_css" /> 是 &nbsp; &nbsp;<input type="radio" value="0" name="settings[isoff]" class="radio_css" /> 否</td><td class="td_2">论坛名称，将显示在导航条和标题中</td></tr>
			<tr><td class="td_0">论坛关闭原因:</td><td class=""></td></tr>
			<tr><td class="td_1"><textarea style="height:70px;width:280px;" name="settings[offdetails]" id="offdetails">{$row['offdetails']}</textarea></td><td class="td_2">论坛关闭时出现的提示信息</td></tr>
			<tr><td class="td_0">论坛第三方统计代码:</td><td class=""></td></tr>
			<tr><td class="td_1"><textarea style="height:70px;width:280px;" name="settings[counter]" id="counter">{$row['counter']}</textarea></td><td class="td_2">页面底部可以显示第三方统计</td></tr>
			<tr><td class="td_0">IP查询链接:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" style="width:280px;" value="{$row['iplink']}" name="settings[iplink]" id="iplink" class="text_css" /></td><td class="td_2">论坛中出现的IP地址的链接，可以方便查询IP的地理位置等信息。</td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savesettings()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div id="t2"></div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
	<script>
	var smallNowTab;
	var pt = new Tabs();
	pt.classpre="smalltab_";
	pt.container = "smalltab_container";
	pt.createTab("t1","论坛基本信息","",true,"n");
	pt.init = function(){
		smallNowTab = pt.nowTab;
	};
	pt.onclick = function(){
		smallNowTab = pt.nowTab;
	};		
	pt.initTab();
	pt.clickNowTab();
	
	var isoff="{$row['isoff']}";
	setRadioCheck("settings[isoff]",isoff);
	
	function ajax_savesettings(){
		if(getV("bbsname")==""){
			var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
			popwin.showDialog(2,"提示","请填写完整必填项<span class='required'>(*)</span>",btns,280,130);
			return;
		}
		popwin.loading();
		ajaxPost("settingsform","main_ajax.php?action=savesettings",ajax_savesettings_callback);
	}
	function ajax_savesettings_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","论坛基本信息修改成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	</script>
EOT;
	break;
	/************************************** settings END ************************************************/


	/************************************** register BEGIN ************************************************/
	case "register":
	$row=getSettings();
echo <<<EOT
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1">
		<form id="signupform1" onsubmit="return false;">
		<table class="table_1">
			<tr><td class="td_0">论坛注册开放:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="radio" value="1" name="settings[issignup]" class="radio_css" /> 是 &nbsp; &nbsp;<input type="radio" value="0" name="settings[issignup]" class="radio_css" /> 否</td><td class="td_2">设置是否允许游客注册成为论坛会员</td></tr>
	
			<tr><td class="td_0">论坛注册文件名:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="30" value="{$row['signupfilename']}" name="settings[signupfilename]" id="signupfilename" class="text_css" /></td><td class="td_2">设置论坛注册页的文件名</td></tr>
	
			<tr><td class="td_0">发送欢迎站内短信:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="radio" value="1" name="settings[iswelcome]" class="radio_css" /> 是 &nbsp; &nbsp;<input type="radio" value="0" name="settings[iswelcome]" class="radio_css" /> 否</td><td class="td_2">是否发送欢迎站内短信</td></tr>
	
			<tr><td class="td_0">欢迎短信标题:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="30" value="{$row['welcometitle']}" name="settings[welcometitle]" id="welcometitle" class="text_css" /></td><td class="td_2">系统发送的欢迎信息的标题</td></tr>
	
			<tr><td class="td_0">欢迎短信内容:</td><td class=""></td></tr>
			<tr><td class="td_1"><textarea style="height:70px;width:280px;" name="settings[welcomecontent]" id="welcomecontent">{$row['welcomecontent']}</textarea></td><td class="td_2">
	系统发送的欢迎信息的内容。标题内容均支持变量替换，可以使用如下变量:<br />
	{username} : 用户名<br />
	{time} : 发送时间<br />
	{bbsname} : 论坛名称<br />
	{url} : 论坛名称<br /></td></tr>
	
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savesigninfo1()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div id="t2" style="display:none;">
		<form id="signupform2" onsubmit="return false;">
		<table class="table_1">
			<tr><td class="td_0">注册审核:</td><td class=""></td></tr>
			<tr><td class="td_1"><select name="settings[issignupverify]" id="settings[issignupverify]"><option value="0">不需要审核</option><option value="1">管理员审核</option><option value="2">用户邮箱激活</option></select></td><td class="td_2">用户必须通过审核才能使用</td></tr>
	
			<tr><td class="td_0">禁用注册关键字:</td><td class=""></td></tr>
			<tr><td class="td_1"><textarea style="height:70px;width:280px;" name="settings[reservedkeyword]" id="reservedkeyword">{$row['reservedkeyword']}</textarea></td><td class="td_2">用户在其用户信息(如昵称、自定义头衔等)中无法使用这些关键字。</td></tr>
	
			<tr><td class="td_0">同一IP注册间隔时间:(小时)</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="30" value="{$row['signupitime']}" name="settings[signupitime]" id="signupitime" class="text_css" /></td><td class="td_2">限制同一个IP必须间隔一定时间之后才能再注册</td></tr>
	
			<tr><td class="td_0">注册之后冻结时间:(小时)</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="30" value="{$row['frozentime']}" name="settings[frozentime]" id="frozentime" class="text_css" /></td><td class="td_2">注册之后冻结一定的时间才能发帖</td></tr>
	
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savesigninfo2()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
	<script>
	var smallNowTab;
	var pt = new Tabs();
	pt.classpre="smalltab_";
	pt.container = "smalltab_container";
	pt.createTab("t1","论坛注册","",true,"n");
	pt.createTab("t2","注册限制","",false,"n");
	pt.init = function(){
		smallNowTab = pt.nowTab;
	};
	pt.onclick = function(){
		smallNowTab = pt.nowTab;
	};		
	pt.initTab();
	pt.clickNowTab();
	
	var issignup="{$row['issignup']}";
	var iswelcome="{$row['iswelcome']}";
	var issignupverify="{$row['issignupverify']}";
	setRadioCheck("settings[issignup]",issignup);
	setRadioCheck("settings[iswelcome]",iswelcome);
	setSelect("settings[issignupverify]",issignupverify);
	
	function ajax_savesigninfo1(){
		popwin.loading();
		ajaxPost("signupform1","main_ajax.php?action=savesignupinfo",ajax_savesigninfo1_callback);
	}
	function ajax_savesigninfo1_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","论坛注册设置修改成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	
	function ajax_savesigninfo2(){
		popwin.loading();
		ajaxPost("signupform2","main_ajax.php?action=savesignupinfo2",ajax_savesigninfo2_callback);
	}
	function ajax_savesigninfo2_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","论坛注册设置修改成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	</script>
EOT;

	break;
	/************************************** register BEGIN ************************************************/



	/************************************** time END ************************************************/
	case "time":
	$row=getSettings();
echo <<<EOT
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1">
		<form id="timeform" onsubmit="return false;">
		<table class="table_1">
			<tr><td class="td_0">论坛时间格式:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="40" value="{$row['timeformat']}" name="settings[timeformat]" id="timeformat" class="text_css" /></td><td class="td_2">使用 yyyy(yy) 表示年，mm 表示月，dd 表示天。如 yyyy-mm-dd 表示 2010-01-01</td></tr>
			<tr><td class="td_0">系统时差:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="40" value="{$row['timeoffset']}" name="settings[timeoffset]" id="timeoffset" class="text_css" /></td><td class="td_2">当地时间与 GMT 的时差</td></tr>
			<tr><td class="td_0">人性化时间格式:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="radio" value="1" name="settings[humantime]" class="radio_css" /> 是 &nbsp; &nbsp;<input type="radio" value="0" name="settings[humantime]" class="radio_css" /> 否</td><td class="td_2">选择“是”，论坛中的时间将以“n秒前”、“n分钟前”等形式显示</td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savetime()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div id="t2"></div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
	<script>
	var smallNowTab;
	var pt = new Tabs();
	pt.classpre="smalltab_";
	pt.container = "smalltab_container";
	pt.createTab("t1","时间设置","",true,"n");
	pt.init = function(){
		smallNowTab = pt.nowTab;
	};
	pt.onclick = function(){
		smallNowTab = pt.nowTab;
	};		
	pt.initTab();
	pt.clickNowTab();

	var humantime="{$row['humantime']}";
	setRadioCheck("settings[humantime]",humantime);

	function ajax_savetime(){
		popwin.loading();
		ajaxPost("timeform","main_ajax.php?action=savetime",ajax_savetime_callback);
	}

	function ajax_savetime_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","论坛时间设置成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	</script>
EOT;
	break;
	/************************************** time END ************************************************/


	/************************************** credits BEGIN ************************************************/
	case "credits":	//积分设置
	$rows=$db->row_select("credits","",0,"*","id");
	$setrow=getSettings();
echo <<<EOT
	<style>
	.td_1{width:600px;}
	</style>
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1">
		<form id="creditsform" onsubmit="return false;">
		<div class="tips_1"><b>积分设置提示</b><br />
		* 使用积分可以提交论坛用户的积极性。</div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1" width="100%">
			<tr style="font-weight:bold;color:#333333;"><td class="td_4"><div class="td_4_1">启用</div><div class="td_4_2">积分代号</div><div class="td_4_3">积分名称</div><div class="td_4_4">发帖</div><div class="td_4_5">回复</div><div class="td_4_6">精华</div><div class="td_4_7">上传</div><div class="td_4_8">下载</div><div class="td_4_9">投票</div></td></tr>

EOT;

			for($i=0;$i<count($rows);$i++){
				$row=$rows[$i];
				echo("<tr><td class=\"td_4\"><div class=\"td_4_1\"><input type=\"hidden\" value=\"{$row['id']}\" name=\"id_{$i}\"><input type=\"checkbox\" name=\"isuse_{$i}\" onclick=\"if(this.checked){this.value=1;}else{this.value=0;}\" ");
				if($row['isuse']==1){
					echo("value=\"1\" checked=\"true\" ");	
				}else{
					echo("value=\"0\" ");	
				}
				echo(" class=\"checkbox_css\" /></div><div class=\"td_4_2\" style=\"font-weight:bold;color:#333333;\">{$row[creditscode]}</div><div class=\"td_4_3\"><input type='text' value='{$row[creditsname]}' size='12' name='creditsname_{$i}'  class=\"text_css\" /></div><div class=\"td_4_4\"><input type='text' value='{$row[postvar]}' size='5' name='postvar_{$i}' class=\"text_css\" /></div><div class=\"td_4_5\"><input type='text' value='{$row[replyvar]}' size='5' name='replyvar_{$i}'  class=\"text_css\" /></div><div class=\"td_4_6\"><input type='text' value='{$row[goodvar]}' size='5' name='goodvar_{$i}' class=\"text_css\" /></div><div class=\"td_4_7\"><input type='text' value='{$row[uploadvar]}' size='5' name='uploadvar_{$i}' class=\"text_css\" /></div><div class=\"td_4_8\"><input type='text' value='{$row[downvar]}' size='5' name='downvar_{$i}' class=\"text_css\" /></div><div class=\"td_4_9\"><input type='text' value='{$row[votevar]}' size='5' name='votevar_{$i}' class=\"text_css\" /></div></td></tr>");				
			}
echo <<<EOT
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savecredits()" /></td></tr>
		</table>
		</form>
	</div>
	<div id="t2">
		<form id="creditsexpform" onsubmit="return false;">
		<div class="tips_1"><b>总积分计算公式</b><br />
		* 请在修改总积分计算公式之后，点击测试计算，测试结果正确方可提交。<br />
		* 可用参数：<b>
EOT;
foreach($cache_credits as $credits){
	echo("({$credits['creditsname']}:{$credits['creditscode']}) ");
}
echo("(帖数:postsnum)");
echo <<<EOT
		</b></div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">总积分计算公式:<span class='required'>(*)</span></td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="80" value="{$setrow['creditsexpression']}" name="settings[creditsexpression]" id="creditsexpression" class="text_css" /></td><td class="td_2">计算公式</td></tr>
			<tr><td class="td_0">测试数据:<span class='required'>(*)</span></td><td class=""></td></tr>
			<tr><td class="td_1">credits1=10, credits2=20, credits3=30, credits4=40, <br />credits5=50, credits6=60, credits7=70, credits8=80<br />postsnum=10<br /><input class="button_css" type="button" value="  测 试  " onclick="ajax_testcreditsexp()" /></td><td class="td_2">可以先进行公式的测试，核对结果后再提交。</td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savecreditsexp()" /></td><td class=""></td></tr>
		</table>
		</form>	
	</div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
	<script>
	var smallNowTab;
	var pt = new Tabs();
	pt.classpre="smalltab_";
	pt.container = "smalltab_container";
	pt.createTab("t1","积分设置提示","",true,"n");
	pt.createTab("t2","总积分计算公式","",false,"n");
	pt.init = function(){
		smallNowTab = pt.nowTab;
	};
	pt.onclick = function(){
		smallNowTab = pt.nowTab;
	};		
	pt.initTab();
	pt.clickNowTab();
	
	
	function ajax_savecredits(){
		popwin.loading();
		ajaxPost("creditsform","main_ajax.php?action=savecredits",ajax_savecredits_callback);
	}
	function ajax_savecredits_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","论坛积分设置修改成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	function ajax_savecreditsexp(){
		if(getV("creditsexpression")==""){
			var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
			popwin.showDialog(2,"提示","请填写完整必填项<span class='required'>(*)</span>",btns,280,130);
			return;
		}
		popwin.loading();
		ajaxPost("creditsexpform","main_ajax.php?action=savecreditsexp",ajax_savecreditsexp_callback);
	}
	
	function ajax_savecreditsexp_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","总积分计算公式修改成功",btns,300,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败: 总积分计算公式错误。", btns,300,130);
		}
	}
	
	function ajax_testcreditsexp(){
		if(getV("creditsexpression")==""){
			var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
			popwin.showDialog(2,"提示","请填写完整必填项<span class='required'>(*)</span>",btns,280,130);
			return;
		}
		popwin.loading();
		ajaxPost("creditsexpform","main_ajax.php?action=testcreditsexp",ajax_testcreditsexp_callback);
	}
	
	function ajax_testcreditsexp_callback(data){
		popwin.loaded();
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		if(data.substring(0,8)=='succeed='){
			data=data.substring(8,data.length);
			popwin.showDialog(2,"测试结果","测试结果为: "+data,btns,300,130);			
		}else{
			popwin.showDialog(0,"测试失败", "操作失败: 总积分计算公式错误。", btns,300,130);
		}

	}

	</script>
EOT;
	break;
	/************************************** credits END ************************************************/

	/************************************** email BEGIN ************************************************/
	case "email":	//邮件设置
	$row=getSettings();
echo <<<EOT
	<style>
	.td_1{width:400px; line-height:200%;}
	</style>
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div id="t1">
		<form id="mailform" onsubmit="return false;">
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">邮件发送方式:<span class='required'>(*)</span></td><td class=""></td></tr>
			<tr>
			<td class="td_1"><input type="radio" value="1" name="settings[mailsendtype]" onclick="changeSendType()" class="radio_css" /> 通过 PHP 函数的 sendmail 发送(推荐此方式)<br /><input type="radio" value="2" name="settings[mailsendtype]" onclick="changeSendType()" class="radio_css" /> 通过 SOCKET 连接 SMTP 服务器发送
				<div id="smtpsetting" class="divintd" style="display:none;">
					<p><span>SMTP 服务器:</span><br /><input type="text" size="35" value="{$row['smtpserver']}" name="settings[smtpserver]" class="text_css" /></p>
					<p><span>SMTP 端口:</span><br /><input type="text" size="35" value="{$row['smtpport']}" name="settings[smtpport]" class="text_css" /></p>
					<p><span>SMTP 服务器要求身份验证:</span><br /><input type="radio" value="1" name="settings[smtpauth]" class="radio_css" /> 是&nbsp; &nbsp; <input type="radio" value="0" name="settings[smtpauth]" class="radio_css" /> 否</p>
					<p><span>发信人邮件地址:</span><br /><input type="text" size="35" value="{$row['smtpsender']}" name="settings[smtpsender]" class="text_css" /></p>
					<p><span>SMTP 身份验证用户名:</span><br /><input type="text" size="35" value="{$row['smtpusername']}" name="settings[smtpusername]" class="text_css" /></p>
					<p><span>SMTP 身份验证密码:</span><br /><input type="password" size="35" value="{$row['smtppassword']}" name="settings[smtppassword]" class="text_css" /></p>
				</div>
			</td>
			<td class="td_2"></td>
			</tr>
			<tr><td class="td_0">测试设置:</td><td class=""></td></tr>
			<tr><td class="td_1">
				<div id="" class="divintd">
					<p><span>测试发件人:</span><br /><input type="text" size="35" value="Tester<test@domain.com>" name="testmail[sender]" class="text_css" /></p>
					<p><span>测试收件人:</span><br /><input type="text" size="35" value="" name="testmail[receiver]" class="text_css" /></p>
					<p><input class="button_css" type="button" value="  测试发送邮件  " onclick="ajax_testmail()" /></p>
				</div>
			</td><td class="td_2"></td></tr>
			<tr><td class="td_3"> <input class="button_css" type="button" value="  保存设置  " onclick="ajax_savemail()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div id="t2"></div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
	<script>
	var smallNowTab;
	var pt = new Tabs();
	pt.classpre="smalltab_";
	pt.container = "smalltab_container";
	pt.createTab("t1","邮件设置","",true,"n");
	pt.init = function(){
		smallNowTab = pt.nowTab;
	};
	pt.onclick = function(){
		smallNowTab = pt.nowTab;
	};		
	pt.initTab();
	pt.clickNowTab();
	
	var mailsendtype="{$row['mailsendtype']}";
	setRadioCheck("settings[mailsendtype]",mailsendtype);
	
	var smtpauth="{$row['smtpauth']}";
	setRadioCheck("settings[smtpauth]",smtpauth);

	function ajax_testmail(){
		popwin.loading();
		ajaxPost("mailform","main_ajax.php?action=testmail",ajax_testmail_callback);
	}
	function ajax_testmail_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"测试邮件","测试邮件已经发送，请留意查收。",btns,320,130);
		}else{
			popwin.showDialog(0,"测试失败","测试失败:<br />"+data,btns,320,130);
		}
	}
	
	function ajax_savemail(){
		popwin.loading();
		ajaxPost("mailform","main_ajax.php?action=savemail",ajax_savemail_callback);
	}
	function ajax_savemail_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"保存成功","邮件设置保存成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	function changeSendType(){
		var type=getRadioValue("settings[mailsendtype]");
		setDisplay('smtpsetting',type==2);
	}
	function InitPage(){
		changeSendType();
	}
	
	window.onload=InitPage;
	
	</script>
EOT;
	break;
	/************************************** email END ************************************************/


	case "bbs":	//论坛功能
	/************************************** bbs BEGIN ************************************************/
	$row=getSettings();
	$gzip_str=extension_loaded('zlib')?"系统检测到服务器支持Gzip压缩":"此服务器不支持Gzip压缩";
echo <<<EOT
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1">
		<form id="bbsform1" onsubmit="return false;">
		<div class="tips_1"><b>管理记录</b><br />
		* 论坛管理工作统计可以使管理员了解版主等管理人员的工作状况。注意:本功能会轻微加重系统负担
		</div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">开启论坛管理工作统计:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="radio" value="1" name="settings[isadminlog]" class="radio_css" /> 是 &nbsp; &nbsp;<input type="radio" value="0" name="settings[isadminlog]" class="radio_css" /> 否</td><td class="td_2"></td></tr>
			<tr><td class="td_0">管理记录保留时间:(天)</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="40" value="{$row['adminlogsavetime']}" name="settings[adminlogsavetime]" id="adminlogsavetime" class="text_css" /></td><td class="td_2">系统中保留管理记录的时间，默认为 30 天，建议在 30～60 天的范围内取值</td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savebbs1()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div id="t2">
		<form id="bbsform2" onsubmit="return false;">
		<div class="tips_1"><b>在线统计</b><br />
		* 设置在线统计的时间间隔，以及最大在线人数的限制。
		</div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">在线保持时间:(分钟)</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="10" value="{$row['onlinekeeptime']}" name="settings[onlinekeeptime]" id="onlinekeeptime" class="text_css" /></td><td class="td_2">论坛统计在线人数的延迟时间。建议填写30。</td></tr>
			<tr><td class="td_0">论坛最大在线人数:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="10" value="{$row['onlinemostnum']}" name="settings[onlinemostnum]" id="onlinemostnum" class="text_css" /></td><td class="td_2">超过该限制之后，访客暂时无法访问论坛。填写0为无限制。</td></tr>
			<tr><td class="td_0">论坛首页详细在线列表人数:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="10" value="{$row['indexmostonline']}" name="settings[indexmostonline]" id="indexmostonline" class="text_css" /></td><td class="td_2">在首页显示的详细在线列表的人数。填写0，则首页只显示在线统计人数，而不显示详细在线列表。</td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savebbs2()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div id="t3">
		<form id="bbsform3" onsubmit="return false;">
		<div class="tips_1"><b>论坛搜索</b><br />
		* 论坛搜索的限制可以节省论坛的资源
		</div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">搜索时间间隔:(秒钟)</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="10" value="{$row['searchitime']}" name="settings[searchitime]" id="searchitime" class="text_css" /></td><td class="td_2"></td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savebbs3()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div id="t4">
		<form id="bbsform4" onsubmit="return false;">
		<div class="tips_1"><b>发帖时间间隔</b><br />
		* 设置发帖子的时间间隔，可以避免论坛灌水、广告帖群发。
		</div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">注册之后冻结时间:(小时)</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="30" value="{$row['frozentime']}" name="settings[frozentime]" id="frozentime" class="text_css" /></td><td class="td_2">注册之后冻结一定的时间才能发帖</td></tr>
			<tr><td class="td_0">发帖时间间隔:(秒钟)</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="10" value="{$row['postitime']}" name="settings[postitime]" id="postitime" class="text_css" /></td><td class="td_2"></td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savebbs4()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div id="t5">
		<form id="bbsform5" onsubmit="return false;">
		<div class="tips_1"><b>显示设置</b><br />
		* 设置每页显示帖子数量、帖子每页显示回复数量等
		</div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">主题列表的每页显示数量:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="10" value="{$row['topicspernum']}" name="settings[topicspernum]" id="topicspernum" class="text_css" /></td><td class="td_2"></td></tr>
			<tr><td class="td_0">帖子每页显示的回复数量:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="10" value="{$row['postspernum']}" name="settings[postspernum]" id="postspernum" class="text_css" /></td><td class="td_2"></td></tr>
			<tr><td class="td_0">会员列表/在线列表每页显示数量:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="10" value="{$row['userspernum']}" name="settings[userspernum]" id="userspernum" class="text_css" /></td><td class="td_2"></td></tr>
			<tr><td class="td_0">会员站内短信每页显示数量:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="10" value="{$row['msgpernum']}" name="settings[msgpernum]" id="msgpernum" class="text_css" /></td><td class="td_2"></td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savebbs5()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div id="t6">
		<form id="bbsform6" onsubmit="return false;">
		<div class="tips_1"><b>页面 Gzip 压缩</b><br />
		* 将页面内容以 gzip 压缩后传输，可以加快传输速度，需 PHP 4.0.4 以上且支持 Zlib 模块才能使用
		</div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">开启页面 Gzip 压缩:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="radio" value="1" name="settings[isgzip]" class="radio_css" /> 是 &nbsp; &nbsp;<input type="radio" value="0" name="settings[isgzip]" class="radio_css" /> 否</td><td class="td_2">{$gzip_str}</td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savebbs6()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div class="div_clear" style="height:30px;"></div>
	<script>
	var smallNowTab;
	var pt = new Tabs();
	pt.classpre="smalltab_";
	pt.container = "smalltab_container";
	//pt.createTab("t1","管理记录","",true,"n");
	pt.createTab("t2","在线统计","",true,"n");
	pt.createTab("t3","论坛搜索","",false,"n");
	pt.createTab("t4","发帖时间","",false,"n");
	pt.createTab("t5","显示设置","",false,"n");
	pt.createTab("t6","Gzip压缩","",false,"n");
	pt.init = function(){
		smallNowTab = pt.nowTab;
	};
	pt.onclick = function(){
		smallNowTab = pt.nowTab;
	};		
	pt.initTab();
	pt.clickNowTab();
	
	var isadminlog="{$row['isadminlog']}";
	setRadioCheck("settings[isadminlog]",isadminlog);
	var isgzip="{$row['isgzip']}";
	setRadioCheck("settings[isgzip]",isgzip);
	
	
	function ajax_savebbs1(){
		popwin.loading();
		ajaxPost("bbsform1","main_ajax.php?action=savebbs1",ajax_savebbs1_callback);
	}
	function ajax_savebbs1_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","管理记录修改成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	function ajax_savebbs2(){
		popwin.loading();
		ajaxPost("bbsform2","main_ajax.php?action=savebbs2",ajax_savebbs2_callback);
	}
	function ajax_savebbs2_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","在线统计修改成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	
	function ajax_savebbs3(){
		popwin.loading();
		ajaxPost("bbsform3","main_ajax.php?action=savebbs3",ajax_savebbs3_callback);
	}
	function ajax_savebbs3_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","论坛搜索修改成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	function ajax_savebbs4(){
		popwin.loading();
		ajaxPost("bbsform4","main_ajax.php?action=savebbs4",ajax_savebbs4_callback);
	}
	function ajax_savebbs4_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","发帖时间间隔修改成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	function ajax_savebbs5(){
		popwin.loading();
		ajaxPost("bbsform5","main_ajax.php?action=savebbs5",ajax_savebbs5_callback);
	}
	function ajax_savebbs5_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","论坛显示设置修改成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	function ajax_savebbs6(){
		popwin.loading();
		ajaxPost("bbsform6","main_ajax.php?action=savebbs6",ajax_savebbs6_callback);
	}
	function ajax_savebbs6_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","页面Gzip压缩设置成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	setDisplay("t1",false);
	
	</script>
EOT;
	break;
	/************************************** bbs END ************************************************/

	/************************************** reward BEGIN ************************************************/
	case "reward":
	$row=getSettings();
	$creditsoption="";
	foreach($cache_credits as $credits){
		$creditsoption.="<option value='{$credits['creditscode']}'>{$credits['creditsname']}</option>";
	}
echo <<<EOT
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div id="t1">
		<form id="rewardform" onsubmit="return false;">
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">悬赏使用积分:<span class='required'>(*)</span></td><td class=""></td></tr>
			<tr><td class="td_1"><select id="settings[rewardcredits]" name="settings[rewardcredits]"><option value='user'>用户发帖时选择</option>{$creditsoption}</select></td><td class="td_2">悬赏帖子使用的积分类型</td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_savereward()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	<div id="t2"></div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
	<script>
	var smallNowTab;
	var pt = new Tabs();
	pt.classpre="smalltab_";
	pt.container = "smalltab_container";
	pt.createTab("t1","悬赏帖子选项","",true,"n");
	pt.init = function(){
		smallNowTab = pt.nowTab;
	};
	pt.onclick = function(){
		smallNowTab = pt.nowTab;
	};		
	pt.initTab();
	pt.clickNowTab();
	
	var rewardcredits="{$row['rewardcredits']}";
	setSelect("settings[rewardcredits]",rewardcredits);
	
	function ajax_savereward(){
		popwin.loading();
		ajaxPost("rewardform","main_ajax.php?action=savereward",ajax_savereward_callback);
	}
	function ajax_savereward_callback(data){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.loaded();
		if(data=="y"){
			popwin.showDialog(1,"修改成功","悬赏帖子选项修改成功",btns,280,130);
		}else{
			popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
		}
	}
	
	</script>
EOT;
	break;
	/************************************** reward END ************************************************/
}	
?>